package com.reggie.mapper;

import com.reggie.pojo.SetmealDish;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SetmealDishMapper {
    @Insert("INSERT INTO setmeal_dish(id, setmeal_id, dish_id, name, price, copies, sort, create_time, update_time, create_user, update_user, is_deleted) " +
            "values (#{id}, #{setmealId}, #{dishId}, #{name}, #{price}, #{copies}, #{sort}, now(), now(), #{createUser}, #{updateUser}, 0)")
    Integer add(SetmealDish setmealDish);

    @Select("SELECT * FROM setmeal_dish WHERE setmeal_id=#{setmealId}")
    List<SetmealDish> find(Long setmealId);

    @Update("UPDATE setmeal_dish SET is_deleted=1, update_time=now(), update_user=#{userId} WHERE id=#{id}")
    int delete(Long id, Long userId);
}
